<template>
  <div id="home">
      <baseinfo></baseinfo>
      <div class="title">
            <i class="el-icon-star-on"></i>
            <span><router-link :to="{path: '/products', query: {msg: 1}}">电子产品</router-link></span>
            <i class="el-icon-star-on"></i>
      </div>
      <div class="showpro">
        
        
        <productBrief
        v-for="item in products.array1"
        :key="item.index"
        :image="item.image"
        :name="item.name"
        :price="item.price"
        :sellername="item.sellerUsername"
        :id="item.id"
        ></productBrief>
        <!-- DEMO -->
        <!-- <productBrief
        v-for="item in 8"
        :key="item.index"
        image="https://img13.360buyimg.com/jdcms/s300x300_jfs/t1/178661/28/3905/138182/609d39a7Eb1a7b045/c6f860d88ffe3ffd.jpg.webp"
        name="百草味 冰雪蛋糕540g/箱
                网红饼干糕点点心整箱早餐手撕小面包麻薯夹心糯米糍"
        price="99.9"
        sellername="百草味官方旗舰店"
        id="3"
        ></productBrief> -->
      </div>
      <div class="title">
            <i class="el-icon-star-on"></i>
            <span><router-link :to="{path: '/products', query: {msg: 2}}">学习文具</router-link></span>
            <i class="el-icon-star-on"></i>
      </div>
      <div class="showpro">
        <productBrief
        v-for="item in products.array2"
        :key="item.index"
        :image="item.image"
        :name="item.name"
        :price="item.price"
        :sellername="item.sellerUsername"
        :id="item.id"
        ></productBrief>
      </div>

      <div class="title">
            <i class="el-icon-star-on"></i>
            <span><router-link :to="{path: '/products', query: {msg: 3}}">生活用品</router-link></span>
            <i class="el-icon-star-on"></i>
      </div>
      <div class="showpro">
        <productBrief
        v-for="item in products.array3"
        :key="item.index"
        :image="item.image"
        :name="item.name"
        :price="item.price"
        :sellername="item.sellerUsername"
        :id="item.id"
        ></productBrief>
      </div>

      <div class="title">
            <i class="el-icon-star-on"></i>
            <span><router-link :to="{path: '/products', query: {msg: 4}}">美妆服饰</router-link></span>
            <i class="el-icon-star-on"></i>
      </div>
      <div class="showpro">
        <productBrief
        v-for="item in products.array4"
        :key="item.index"
        :image="item.image"
        :name="item.name"
        :price="item.price"
        :sellername="item.sellerUsername"
        :id="item.id"
        ></productBrief>
      </div>

      <div class="title">
            <i class="el-icon-star-on"></i>
            <span><router-link :to="{path: '/products', query: {msg: 5}}">教材图书</router-link></span>
            <i class="el-icon-star-on"></i>
      </div>
      <div class="showpro">
        <productBrief
        v-for="item in products.array5"
        :key="item.index"
        :image="item.image"
        :name="item.name"
        :price="item.price"
        :sellername="item.sellerUsername"
        :id="item.id"
        ></productBrief>
      </div>

      <div class="title">
            <i class="el-icon-star-on"></i>
            <span><router-link :to="{path: '/products', query: {msg: 6}}">食品饮料</router-link></span>
            <i class="el-icon-star-on"></i>
      </div>
      <div class="showpro">
        <productBrief
        v-for="item in products.array6"
        :key="item.index"
        :image="item.image"
        :name="item.name"
        :price="item.price"
        :sellername="item.sellerUsername"
        :id="item.id"
        ></productBrief>
      </div>

      <div class="title">
            <i class="el-icon-star-on"></i>
            <span><router-link :to="{path: '/products', query: {msg: 7}}">精美礼品</router-link></span>
            <i class="el-icon-star-on"></i>
      </div>
      <div class="showpro">
        <productBrief
        v-for="item in products.array7"
        :key="item.index"
        :image="item.image"
        :name="item.name"
        :price="item.price"
        :sellername="item.sellerUsername"
        :id="item.id"
        ></productBrief>
      </div>

      <div class="title">
            <i class="el-icon-star-on"></i>
            <span><router-link :to="{path: '/products', query: {msg: 8}}">休闲娱乐</router-link></span>
            <i class="el-icon-star-on"></i>
      </div>
      <div class="showpro">
        <productBrief
        v-for="item in products.array8"
        :key="item.index"
        :image="item.image"
        :name="item.name"
        :price="item.price"
        :sellername="item.sellerUsername"
        :id="item.id"
        ></productBrief>
      </div>

      <div class="title">
            <i class="el-icon-star-on"></i>
            <span><router-link :to="{path: '/products', query: {msg: 9}}">其他</router-link></span>
            <i class="el-icon-star-on"></i>
      </div>
      <div class="showpro">
        <productBrief
        v-for="item in products.array9"
        :key="item.index"
        :image="item.image"
        :name="item.name"
        :price="item.price"
        :sellername="item.sellerUsername"
        :id="item.id"
        ></productBrief>
      </div>

      <div class="title">
          <i class="el-icon-star-on"></i>
          <span><router-link to="/needMarket">需求市集</router-link></span>
          <i class="el-icon-star-on"></i>
      </div>
      <div id="showneed">
        <need 
          v-for="item in products.array10" 
          :key="item.index"
          :image="item.image"
          :username="item.username"
          :needTime="item.time"
          :description="item.description"
        ></need>
      </div>
  </div>
</template>

<script>
import {request} from '../network/request';
import baseinfo from '../components/baseinfo.vue'
import productBrief from '../components/productBrief.vue'
import need from '../components/need.vue'

export default {
  name: 'Home',
  components: {
    baseinfo,productBrief, need
  },
  data() {
    return {
      products: '',
    }
  },
  created() {
    request({
      url: '/',
      method: 'get'
    }).then(res => {
      this.products = res.data
    })
  }
}
</script>

<style scoped>
#home {
  background-color: rgb(232,232,232);
}

.showpro {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
}


.title {
    text-align: center;
    font-size: 28px;
    font-weight: bold;
    padding-top: 25px;
    padding-bottom: 20px;
    margin: 0 auto;
    display: flex;
    justify-content: space-around;
    width: 200px;
}

.title i {
    padding: 5px;
}
</style>